package basis.第十四章;


import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class Example4 {
    static int counter = 0;
    public static void main(String[] args) throws Exception {
        Callable<Integer> callable = new Callable<Integer>() {
            @Override
            public Integer call() throws Exception {
                System.out.println("任务代码");
                return 123;
            }
        };
        FutureTask<Integer> ft = new FutureTask<>(callable);

        Thread t1 = new Thread(ft);
        t1.start();
        System.out.println(ft.get());
    }
}
